﻿@*
@model IEnumerable<Core.Models.File>
*@

@{
    ViewBag.Title = "File Manager";
    Layout = ((Core.Models.Theme)Session["Theme"]).Layout;
    string BUId = ViewBag.BusinessUnitId.ToString();
}

<h1>File Manager for @ViewBag.BusinessUnitName</h1>

<p>
    @Html.ActionLink("Upload File", "Upload", new { id = BUId})
</p>
@Html.Hidden("hdnBusinessUnitId",BUId)
<div id="dynamic">
<table id="tblFile" cellspacing="0" cellpadding="10" width="100%" >
<thead>
    <tr>
        <th></th>
        <th>
            Description
        </th>
        <th>
            Filename
        </th>
        <th>
            Tag(s)
        </th>
        <th>
            Size
        </th>
        <th>
            Last Accessed
        </th>
    </tr>
</thead>
<tbody>
	<tr>
		<td colspan="5" class="dataTables_empty"><img src="@Url.Content("/Content/Images/busy.gif")" alt="Busy" />Loading data from server</td>
	</tr>
</tbody>
</table>
</div>
<div class="spacer"></div>
<script type="text/javascript" language="javascript">
    $(function () {
        $('#tblFile').dataTable({
            "aoColumnDefs": [
            { "bSortable": false, "aTargets": [0] },
			{ "sClass": "nowrap", "aTargets": [0] },
			{ "sName": "description", "aTargets": [1] },
			{ "sName": "filename", "aTargets": [2] },
			{ "sName": "tag", "aTargets": [3] },
			{ "sClass": "rightcell", "aTargets": [4] },
			{ "sName": "size", "aTargets": [4] },
			{ "sClass": "nowrap, rightcell", "aTargets": [5] },
			{ "sName": "lastaccesseddt", "aTargets": [5] }
		],
            "sPaginationType": "full_numbers",
            "iDisplayLength": 15,
            "aLengthMenu": [[15, 25, 50], [15, 25, 50]],
            "bStateSave": true,
            "bJQueryUI": true,
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "/File/ListData",
            "fnServerData": function (sSource, aoData, fnCallback) {
                aoData.push({ "name": "BusinessUnitId", "value": $("#hdnBusinessUnitId").val() });
                $.ajax({
                    "dataType": 'json',
                    "type": "POST",
                    "url": sSource,
                    "data": aoData,
                    "success": fnCallback
                });
            }
        });
    });
</script>
